home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 026-050 / scopedisk46 / mj-pgs / mj.gen_t < prev    next >
Text File  |  1995-03-18  |  7KB  |  226 lines

  1. PRINT TAB(24)"Universal Mandel-Julia Generator"
  2. 'Martin F. Combs 
  3. 'minor modifications to Basic Code by A. Wachtel
  4.  
  5. 'The program is converted from floating point to integer by scaling up
  6. 'by a factor of 2^28, which gives approximately the precision of single
  7. 'precision floating point, but is a lot faster.  All multiplications are
  8. 'followed by dividing by the scale factor.  An ASCII file of the assembly
  9. 'language program can be viewed by entering the CLI and using 
  10. 'type juliasize.asc
  11.  
  12. start:CLEAR ,40000&,10000
  13. width77:DEFINT h,j-l,n,v:DEFLNG m,p,s:DEFDBL c,i,r,t:DIM para(100)
  14. scale=268435456&:DEF FNa(x)=INT(x*10000000&+.5)/10000000&
  15. PRINT "Iterations are terminated when x^2+y^2>4.
  16. INPUT "max. size (*scale - use power of 2 =< 4096)";jsizelimit
  17. para(98)=30-LOG(jsizelimit+1)/LOG(2)
  18. type: INPUT "Enter j for Julia Set, m for Mandelbrot Set  ",typeflag$
  19. IF typeflag$="j" THEN 
  20.   title$="Julia":offset=98 
  21.   INPUT "is this for a symmetric plot (y/n)";w$:GOTO carryon
  22. END IF
  23. IF typeflag$="m" THEN title$="Mandelbrot" ELSE GOTO type
  24. carryon: 
  25. DIM n(6100),jcolors(6100),br(15)
  26. PRINT "# of horizontal pixels calc'd"
  27. PRINT " (max=632 write or  312 plot)";
  28.   IF w$="y" THEN PRINT " -use an even number";
  29.   INPUT horpix: IF w$="y" THEN hor=horpix/2-1 ELSE hor=horpix-1
  30. INPUT "# of vertical pixels (max=387 write or 187 plot)";verpix
  31. IF typeflag$="m" THEN jumparound  
  32. INPUT "Real part of c";creal:para(1)=scale*creal
  33. INPUT "Imaginary part of c";cimag:para(2)=scale*cimag 
  34. jumparound:
  35. INPUT "Real left limit";realleft
  36. INPUT "Real right limit";realright:realrange=realright-realleft
  37. INPUT "Imaginary Lower Limit";imaglow
  38. INPUT "Imaginary Upper Limit ";imaghigh:imagrange=imaghigh-imaglow
  39. rstepreal=realrange*scale/horpix :stepreal=rstepreal
  40. stepimag=imagrange*scale/verpix
  41. PRINT "Horizontal step size should be ";rstepreal;" and is ";stepreal
  42. PRINT "Vertical stepsize =";stepimag
  43. para(1+offset)=scale*realleft
  44. scaleimaglow=scale*imaglow
  45. p1=para(1):p2=para(2):p99=para(99):p100=para(100)
  46. INPUT"do you want to plot or write files (p/w)";mode$
  47. replot:INPUT"highest iter.count";para(0)
  48.        INPUT"lowest count in region (est'd)";ja
  49.  
  50. IF mode$="p" THEN continue
  51.  
  52. INPUT"name of region to be explored (include path)";region$
  53. count$=region$+".count_B" 
  54. stat$=region$+".stat_D"
  55. inform$=region$+".inform_D"
  56. OPEN "O",#1,count$,3000&
  57. PRINT:PRINT TAB(13)"Number Crunching - please blank screen and be patient."
  58. GOTO MLcode
  59.  
  60. continue:
  61. IF w$<>"y" THEN GOSUB breakpoints
  62. PRINT"TO CLEAR PLOT SCREEN OR RERUN PROGRAM, PRESS <RETURN>"
  63. PRINT "press any key to continue":WHILE INKEY$="":WEND
  64. para(1)=p1:para(2)=p2:para(99)=p99:para(100)=p100
  65. SCREEN 3,320,200,4,1:WINDOW 2,title$,,0,3
  66. CLS:GOSUB newcolor
  67.  
  68. MLcode:
  69. j=0:k=0:l=0:t=TIMER
  70. startcode=VARPTR(para(25))
  71.  
  72. again: READ j
  73.   IF j=999 THEN quit
  74.   POKE startcode+k,j
  75.   k=k+1:GOTO again
  76. quit:
  77. RESTORE
  78. IF mode$="p" GOTO plot
  79. IF typeflag$="j" THEN 
  80.   FOR j=0 TO hor 
  81.     para(99)=para(99)+stepreal
  82.     para(100)=scaleimaglow
  83.     FOR k=0 TO verpix-1
  84.       para(100)=para(100)+stepimag
  85.       CALL startcode
  86.       l=para(3)
  87.       n(l)=n(l)+1
  88.       PRINT #1,MKI$(l);
  89.     NEXT:NEXT
  90. ELSE
  91.   FOR j=0 TO hor 
  92.     para(1)=para(1)+stepreal
  93.     para(2)=scaleimaglow
  94.     FOR k=0 TO verpix-1
  95.       para(2)=para(2)+stepimag
  96.       CALL startcode
  97.       l=para(3)
  98.       n(l)=n(l)+1
  99.       PRINT #1,MKI$(l);
  100.     NEXT:NEXT
  101. END IF
  102. CLOSE#1
  103.  
  104. OPEN "O",#2,stat$
  105.   FOR l=1 TO para(0)+jsizelimit:WRITE#2,n(l):NEXT
  106. CLOSE#2
  107.  
  108. OPEN "O",#3,inform$
  109. PRINT#3,region$
  110. WRITE#3,horpix,verpix,w$,typeflag$
  111. WRITE#3,ja,para(0),jsizelimit
  112. PRINT#3,"The above data are for reading by a plot or other program"
  113. PRINT#3,"and represent the following:"
  114. PRINT#3,"# of horiz.pixels, # of vert. pixels, 'y'=symmetric"
  115. PRINT#3,"min.count, max.count (limit), size^2=4 expanded to this #,"
  116. PRINT#3,"type (m = Mandelbrot, j = Julia Set)"
  117. PRINT#3,""
  118. PRINT#3,"The data below are for general reference only:"
  119. IF typeflag$="j" THEN PRINT#3,"Julia set" ELSE PRINT#3,"Mandelbrot"
  120. IF w$="y" THEN PRINT#3,"symmetric"
  121. PRINT#3,"real left and right limits are:  ";FNa(realleft);"   ";FNa(realright)
  122. PRINT#3,"imag.lower and upper limits are: ";FNa(imaglow);"   ";FNa(imaghigh)
  123. IF typeflag$="j" THEN PRINT#3,"real and imag. values of c are:  ";FNa(creal);"   ";FNa(cimag)
  124. CLOSE#3
  125.       
  126. finish: ti=TIMER-t
  127. ah=ti/3600:am=(ah-INT(ah))*60:bs=(am-INT(am))*60
  128. PRINT "time="INT(ah)":"INT(am)":"CINT(bs)
  129. WHILE INKEY$<>CHR$(13):WEND
  130. SCREEN CLOSE 3:WINDOW CLOSE 2
  131. INPUT"type a1 to replot the same area or a2 to rerun pgm";again$
  132. IF again$="a1" THEN CLS:GOTO replot
  133. IF again$="a2" THEN CLS:GOTO start
  134. END
  135.  
  136. plot:
  137. IF typeflag$="j" THEN
  138.   IF w$="y" THEN GOTO symplot
  139.   FOR j=0 TO hor 
  140.     para(99)=para(99)+stepreal
  141.     para(100)=scaleimaglow
  142.     FOR k=0 TO verpix-1
  143.       para(100)=para(100)+stepimag
  144.       CALL startcode
  145.       PSET (j,verpix-1-k),jcolors(para(3))
  146.     NEXT:NEXT
  147. ELSE
  148.   FOR j=0 TO hor 
  149.     para(1)=para(1)+stepreal
  150.     para(2)=scaleimaglow
  151.     FOR k=0 TO verpix-1
  152.       para(2)=para(2)+stepimag
  153.       CALL startcode
  154.       PSET (j,verpix-1-k),jcolors(para(3))
  155.     NEXT:NEXT
  156. END IF
  157. GOTO finish
  158.  
  159. symplot:
  160.   FOR j=0 TO hor 
  161.     para(99)=para(99)+stepreal
  162.     para(100)=scaleimaglow
  163.     FOR k=0 TO verpix-1
  164.       para(100)=para(100)+stepimag
  165.       CALL startcode
  166.       PSET (j,verpix-1-k),para(3) MOD 16
  167.       PSET (horpix-1-j,k),para(3) MOD 16
  168.     NEXT:NEXT
  169. GOTO finish    
  170.  
  171. newcolor:
  172. PALETTE 0,0,0,0       'black
  173. PALETTE 1,1,1,1       'white
  174. PALETTE 2,1,1,0       'yellow
  175. PALETTE 3,.67,.87,0
  176. PALETTE 4,0,1,0
  177. PALETTE 5,0,.8,.47    'green
  178. PALETTE 6,0,.53,.67
  179. PALETTE 7,0,.4,.8
  180. PALETTE 8,0,.2,1      'blue
  181. PALETTE 9,.53,0,1
  182. PALETTE 10,.73,0,.8
  183. PALETTE 11,1,0,.73    'purple
  184. PALETTE 12,1,.4,.6
  185. PALETTE 13,1,.53,.6   'pink
  186. PALETTE 14,1,.67,.8
  187. PALETTE 15,1,1,1      'white
  188. RETURN
  189.  
  190. breakpoints:
  191. n=15:jb=para(0)-ja:PRINT "breakpoints are:"
  192. d=EXP(LOG(jb)/(n-1)):br(1)=1:FOR j=2 TO n:br(j)=br(j-1)*d:NEXT
  193. FOR j=1 TO n-1:br(j)=CINT(ja+br(j)):IF br(j)<=br(j-1) THEN br(j)=br(j-1)+1
  194. PRINT br(j);:NEXT:br(n)=para(0)-1:PRINT br(n)
  195. jj=1:FOR j=1 TO para(0)+jsizelimit-1:jcolors(j)=jj
  196.   IF j=br(jj) THEN jj=jj+1
  197.   NEXT
  198. RETURN
  199.   
  200. DATA 72,231,255,255,75,250,255,150
  201. DATA 32,45,1,140,40,45,1,144,32,124
  202. DATA 0,0,0,0,34,109,0,4,36,109
  203. DATA 0,8,96,94,82,72,158,142,222,137
  204. DATA 118,0,43,64,0,16,106,6,118,1
  205. DATA 68,173,0,16,43,68,0,20,106,6
  206. DATA 82,131,68,173,0,20,50,45,0,16
  207. DATA 194,237,0,22,52,45,0,18,196,237
  208. DATA 0,20,210,130,124,11,236,169,52,45
  209. DATA 0,18,196,237,0,22,124,27,236,170
  210. DATA 210,130,52,45,0,16,196,237,0,20
  211. DATA 235,138,210,130,12,3,0,1,102,2
  212. DATA 68,129,210,138,40,1,32,7,118,0
  213. DATA 43,64,0,16,97,44,74,3,102,30
  214. DATA 46,1,43,68,0,16,97,32,74,3
  215. DATA 102,18,44,65,210,135,177,213,103,74
  216. DATA 178,188,64,0,0,0,107,0,255,122
  217. DATA 43,72,0,12,76,223,255,255,78,117
  218. DATA 106,4,68,173,0,16,50,45,0,18
  219. DATA 194,237,0,18,124,28,236,169,52,45
  220. DATA 0,16,196,237,0,18,124,11,236,170
  221. DATA 210,130,52,45,0,16,196,237,0,16
  222. DATA 180,188,4,0,0,0,90,195,233,138
  223. DATA 210,130,78,117,178,188,64,0,0,0
  224. DATA 108,184,38,45,1,136,230,169,209,193
  225. DATA 96,174,999
  226.